package com.chen.servicepassenger.controller;

import com.chen.internalcommon.dto.ResponseResult;
import com.chen.internalcommon.request.LoginOrRegisterRequest;
import com.chen.servicepassenger.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author chenLiuPing
 **/
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @PostMapping("/user")
    public ResponseResult loginOrRegister(@RequestBody LoginOrRegisterRequest loginOrRegisterRequest) {
        return userService.loginOrRegister(loginOrRegisterRequest.getPassengerPhone());
    }

    @GetMapping("/user{phone}")
    public ResponseResult getUser(@PathVariable("phone") String passengerPhone) {
        return userService.getUser(passengerPhone);
    }
}
